package liecai_class.day09;

import java.nio.CharBuffer;

/**
 * Buffer 缓冲区
 */
public class Demo05 {
    public static void main(String[] args) {
        //1.创建指定容量的空Buffer
        CharBuffer buf1 = CharBuffer.allocate(5);
        //2.将一个数组转换为Buffer
        char [] arr = "hello jara".toCharArray();
        CharBuffer buf2 = CharBuffer.wrap(arr);
        CharBuffer buf3 = CharBuffer.wrap(arr, 0, 5);
        //3.缓冲区的三个游标
        System.out.println(buf1.capacity());
        System.out.println(buf1.limit());
        System.out.println(buf1.position());
        buf1.limit(3);
        buf1.position(2);
    }
}
